package com.zzl.study.auth.security.authentication.context;

import lombok.Data;
import org.springframework.security.oauth2.core.oidc.AddressStandardClaim;

/**
 * @author: zhangzl
 * @date: 2024/6/6 15:47
 * @version: 1.0
 * @description: 地址
 */
@Data
public class Address {

    private String formatted;

    private String streetAddress;

    private String locality;

    private String region;

    private String postalCode;

    private String country;

    public static Address of(AddressStandardClaim addressStandardClaim) {
        if (addressStandardClaim == null) {
            return null;
        }
        Address address = new Address();
        address.setFormatted(addressStandardClaim.getFormatted());
        address.setStreetAddress(addressStandardClaim.getStreetAddress());
        address.setLocality(addressStandardClaim.getLocality());
        address.setRegion(addressStandardClaim.getRegion());
        address.setPostalCode(addressStandardClaim.getPostalCode());
        address.setCountry(addressStandardClaim.getCountry());
        return address;
    }
}
